<template>
  <div class="container">
    <div class="content">
      <el-carousel
        height="200px"
        direction="vertical"
        :interval="2000"
        :autoplay="true"
      >
        <el-carousel-item v-for="(item, index) in data" :key="index">
          <ul>
            <li>
              <span> {{ item.title }}</span>
            </li>
            <li>
              <span>{{ item.content }}</span>
            </li>
            <li>
              {{
                item.createtime.split("T")[0] +
                " " +
                item.createtime.split("T")[1].split(".")[0]
              }}
            </li>
            <li>
              <span @click="toMessage" style="cursor: pointer">更多</span>
            </li>
          </ul>
        </el-carousel-item>
      </el-carousel>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      data: "",
    };
  },
  methods: {
    toMessage() {
      this.$router.push("/service/postMessage");
    },
    getData() {
      this.$Axios({
        url: "/poster/getPosterData",
        method: "get",
        data: {
          currPage: 0,
          pageNum: 100,
        },
        success: (res) => {
          // console.log(res);
          this.data = res.data;
          // console.log(this.data);
        },
      });
    },
  },
  created() {
    this.getData();
  },
};
</script>

<style lang="scss" scoped>
.el-carousel__item h3 {
  color: #475669;
  font-size: 14px;
  opacity: 0.75;
  line-height: 200px;
  margin: 0;
}

.el-carousel__item:nth-child(2n) {
  background-color: #ffffff;
}

.el-carousel__item:nth-child(2n + 1) {
  background-color: #ffffff;
}
.container {
  .content {
    height: 60px;
    overflow: hidden;

    transform: 1s ease;

    ul {
      display: flex;
      flex-direction: row;
      justify-content: space-around;
      li {
        padding: 10px;
        padding-top: 20px;
        padding-bottom: 20px;
      }
      li:nth-child(1) {
        span {
          width: 300px;
          display: inline-block;
          overflow: hidden; /* 隐藏超出部分 */
          white-space: nowrap; /* 禁止换行 */
          text-overflow: ellipsis; /* 使用省略号表示被隐藏的文本 */
        }
      }
      li:nth-child(2) {
        span {
          width: 300px;
          display: inline-block;
          overflow: hidden; /* 隐藏超出部分 */
          white-space: nowrap; /* 禁止换行 */

          text-overflow: ellipsis; /* 使用省略号表示被隐藏的文本 */
        }
      }
      li:nth-child(4) {
        list-style-type: none;
        span {
          font-weight: bold;
          color: #1296db;
        }
      }
    }
  }
}
</style>